﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProyectoVeranoAECAasp.Clases;

namespace ProyectoVeranoAECAasp.Vistas
{
    public partial class BandejaFuncionario : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int IDusuario = Global.get_IDUsuarioEnSesion();
            Label3.Text = IDusuario.ToString();
            GridView1.DataBind();
            this.NombreEtiquetaGroup.Text = Global.get_nombreUserLog();
            this.LoginEtiquetaGroup.Text = Global.get_loginUserLog();
            this.TipoUsuarioGroup.Text = Global.get_tipoUserLog();
        }

        protected void LinkButtonSalir_Click(object sender, EventArgs e)
        {
            Session["UsuarioID"] = null;
            Session["TipoUsuarioGlobal"] = null;
            Response.Redirect("/Vistas/Autenticacion.aspx");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            


           // int id = 0;
           // id = Convert.ToInt32(this.TextBox1.Text);
           // this.Label3.Text = id.ToString(); 
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextBox1.Text = GridView1.SelectedRow.Cells[1].Text;
            LabelError.Text = "";
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if ( TextBox1.Text.CompareTo("") == 0)
                LabelError.Text = "Primero debe seleccionar una reservacion";
            else
            {
                LabelError.Text = "";
                SqlDataSource1.DeleteParameters.Clear();

                String i;
                i = this.TextBox1.Text;
                int f;
                f = Convert.ToInt32(i);
                SqlDataSource1.DeleteParameters.Add(@"ID_Solicitud", i);
                SqlDataSource1.Delete();
                GridView1.DataBind();
                TextBox1.Text = "";
                GridView1.SelectedIndex = -1;
            }
        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        protected void GridView1_PageIndexChanged(object sender, EventArgs e)
        {

            GridView1.SelectedIndex = -1;
            TextBox1.Text = "";
        }

        protected void GridView1_Sorted(object sender, EventArgs e)
        {
            GridView1.SelectedIndex = -1;
            TextBox1.Text = "";
        }
    }
}